package com.wzj.manage.controller;

import com.wzj.manage.entity.Manager;
import com.wzj.manage.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.thymeleaf.util.StringUtils;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("index")
public class LoginController {
    @Autowired
    public ManagerService managerService;
    @RequestMapping("login1")
    public String login(Manager manager, HttpSession session, Model model) {
        System.out.println(manager);
        List<Manager> managers = managerService.selectManager(manager);
        String managerAccount = manager.getManagerAccount();
        String managerPassword = manager.getManagerPassword();
        if(managers.size()>0){

                model.addAttribute("msg1",managers.get(0).getManagerName());
                return "index";
        }
       else{
            model.addAttribute("msg1","用户名或密码错误，请重新登录");
            return "login";
        }
    }
}
